home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Database Designers / Rational Rose 2000 / Rational Setup.EXE / common / lib / MSWin32-x86 / CORE / perlsdio.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-26  |  9.3 KB  |  323 lines

  1. /*
  2.  * Although we may not want stdio to be used including <stdio.h> here 
  3.  * avoids issues where stdio.h has strange side effects
  4.  */
  5. #include <stdio.h>
  6.  
  7. #ifdef PERLIO_IS_STDIO
  8. /*
  9.  * Make this as close to original stdio as possible.
  10.  */
  11. #define PerlIO                FILE 
  12. #define PerlIO_stderr()            stderr
  13. #define PerlIO_stdout()            stdout
  14. #define PerlIO_stdin()            stdin
  15.  
  16. #define PerlIO_printf            fprintf
  17. #define PerlIO_stdoutf            printf
  18. #define PerlIO_vprintf(f,fmt,a)        vfprintf(f,fmt,a)          
  19. #define PerlIO_write(f,buf,count)    fwrite1(buf,1,count,f)
  20. #define PerlIO_open            fopen
  21. #define PerlIO_fdopen            fdopen
  22. #define PerlIO_reopen        freopen
  23. #define PerlIO_close(f)            fclose(f)
  24. #define PerlIO_puts(f,s)        fputs(s,f)
  25. #define PerlIO_putc(f,c)        fputc(c,f)
  26. #if defined(VMS)
  27. #  if defined(__DECC)
  28.      /* Unusual definition of ungetc() here to accomodate fast_sv_gets()'
  29.       * belief that it can mix getc/ungetc with reads from stdio buffer */
  30.      int decc$ungetc(int __c, FILE *__stream);
  31. #    define PerlIO_ungetc(f,c) ((c) == EOF ? EOF : \
  32.             ((*(f) && !((*(f))->_flag & _IONBF) && \
  33.             ((*(f))->_ptr > (*(f))->_base)) ? \
  34.             ((*(f))->_cnt++, *(--(*(f))->_ptr) = (c)) : decc$ungetc(c,f)))
  35. #  else
  36. #    define PerlIO_ungetc(f,c)        ungetc(c,f)
  37. #  endif
  38.    /* Work around bug in DECCRTL/AXP (DECC v5.x) and some versions of old
  39.     * VAXCRTL which causes read from a pipe after EOF has been returned
  40.     * once to hang.
  41.     */
  42. #  define PerlIO_getc(f) \
  43.         (feof(f) ? EOF : getc(f))
  44. #  define PerlIO_read(f,buf,count) \
  45.         (feof(f) ? 0 : (SSize_t)fread(buf,1,count,f))
  46. #else
  47. #  define PerlIO_ungetc(f,c)        ungetc(c,f)
  48. #  define PerlIO_getc(f)        getc(f)
  49. #  define PerlIO_read(f,buf,count)    (SSize_t)fread(buf,1,count,f)
  50. #endif
  51. #define PerlIO_eof(f)            feof(f)
  52. #define PerlIO_getname(f,b)        fgetname(f,b)
  53. #define PerlIO_error(f)            ferror(f)
  54. #define PerlIO_fileno(f)        fileno(f)
  55. #define PerlIO_clearerr(f)        clearerr(f)
  56. #define PerlIO_flush(f)            Fflush(f)
  57. #define PerlIO_tell(f)            ftell(f)
  58. #if defined(VMS) && !defined(__DECC)
  59.    /* Old VAXC RTL doesn't reset EOF on seek; Perl folk seem to expect this */
  60. #  define PerlIO_seek(f,o,w)    (((f) && (*f) && ((*f)->_flag &= ~_IOEOF)),fseek(f,o,w))
  61. #else
  62. #  define PerlIO_seek(f,o,w)        fseek(f,o,w)
  63. #endif
  64. #ifdef HAS_FGETPOS
  65. #define PerlIO_getpos(f,p)        fgetpos(f,p)
  66. #endif
  67. #ifdef HAS_FSETPOS
  68. #define PerlIO_setpos(f,p)        fsetpos(f,p)
  69. #endif
  70.  
  71. #define PerlIO_rewind(f)        rewind(f)
  72. #define PerlIO_tmpfile()        tmpfile()
  73.  
  74. #define PerlIO_importFILE(f,fl)        (f)            
  75. #define PerlIO_exportFILE(f,fl)        (f)            
  76. #define PerlIO_findFILE(f)        (f)            
  77. #define PerlIO_releaseFILE(p,f)        ((void) 0)            
  78.  
  79. #ifdef HAS_SETLINEBUF
  80. #define PerlIO_setlinebuf(f)        setlinebuf(f);
  81. #else
  82. #define PerlIO_setlinebuf(f)        setvbuf(f, Nullch, _IOLBF, 0);
  83. #endif
  84.  
  85. /* Now our interface to Configure's FILE_xxx macros */
  86.  
  87. #ifdef USE_STDIO_PTR
  88. #define PerlIO_has_cntptr(f)        1       
  89. #define PerlIO_get_ptr(f)        FILE_ptr(f)          
  90. #define PerlIO_get_cnt(f)        FILE_cnt(f)          
  91.  
  92. #ifdef STDIO_CNT_LVALUE
  93. #define PerlIO_canset_cnt(f)        1      
  94. #ifdef STDIO_PTR_LVALUE
  95. #define PerlIO_fast_gets(f)        1        
  96. #endif
  97. #define PerlIO_set_cnt(f,c)        (FILE_cnt(f) = (c))          
  98. #else
  99. #define PerlIO_canset_cnt(f)        0      
  100. #define PerlIO_set_cnt(f,c)        abort()
  101. #endif
  102.  
  103. #ifdef STDIO_PTR_LVALUE
  104. #define PerlIO_set_ptrcnt(f,p,c)    (FILE_ptr(f) = (p), PerlIO_set_cnt(f,c))          
  105. #else
  106. #define PerlIO_set_ptrcnt(f,p,c)    abort()
  107. #endif
  108.  
  109. #else  /* USE_STDIO_PTR */
  110.  
  111. #define PerlIO_has_cntptr(f)        0
  112. #define PerlIO_canset_cnt(f)        0
  113. #define PerlIO_get_cnt(f)        (abort(),0)
  114. #define PerlIO_get_ptr(f)        (abort(),(void *)0)
  115. #define PerlIO_set_cnt(f,c)        abort()
  116. #define PerlIO_set_ptrcnt(f,p,c)    abort()
  117.  
  118. #endif /* USE_STDIO_PTR */
  119.  
  120. #ifndef PerlIO_fast_gets
  121. #define PerlIO_fast_gets(f)        0        
  122. #endif
  123.  
  124.  
  125. #ifdef FILE_base
  126. #define PerlIO_has_base(f)        1         
  127. #define PerlIO_get_base(f)        FILE_base(f)         
  128. #define PerlIO_get_bufsiz(f)        FILE_bufsiz(f)       
  129. #else
  130. #define PerlIO_has_base(f)        0
  131. #define PerlIO_get_base(f)        (abort(),(void *)0)
  132. #define PerlIO_get_bufsiz(f)        (abort(),0)
  133. #endif
  134. #else /* PERLIO_IS_STDIO */
  135. #ifdef PERL_CORE
  136. #ifndef PERLIO_NOT_STDIO
  137. #define PERLIO_NOT_STDIO 1
  138. #endif
  139. #endif
  140. #ifdef PERLIO_NOT_STDIO
  141. #if PERLIO_NOT_STDIO
  142. /*
  143.  * Strong denial of stdio - make all stdio calls (we can think of) errors
  144.  */
  145. #include "nostdio.h"
  146. #undef fprintf
  147. #undef tmpfile
  148. #undef fclose
  149. #undef fopen
  150. #undef vfprintf
  151. #undef fgetc
  152. #undef fputc
  153. #undef fputs
  154. #undef ungetc
  155. #undef fread
  156. #undef fwrite
  157. #undef fgetpos
  158. #undef fseek
  159. #undef fsetpos
  160. #undef ftell
  161. #undef rewind
  162. #undef fdopen
  163. #undef popen
  164. #undef pclose
  165. #undef getw
  166. #undef putw
  167. #undef freopen
  168. #undef setbuf
  169. #undef setvbuf
  170. #undef fscanf
  171. #undef fgets
  172. #undef getc_unlocked
  173. #undef putc_unlocked
  174. #define fprintf    _CANNOT _fprintf_
  175. #define stdin      _CANNOT _stdin_
  176. #define stdout     _CANNOT _stdout_
  177. #define stderr     _CANNOT _stderr_
  178. #define tmpfile()  _CANNOT _tmpfile_
  179. #define fclose(f)  _CANNOT _fclose_
  180. #define fflush(f)  _CANNOT _fflush_
  181. #define fopen(p,m)  _CANNOT _fopen_
  182. #define freopen(p,m,f)  _CANNOT _freopen_
  183. #define setbuf(f,b)  _CANNOT _setbuf_
  184. #define setvbuf(f,b,x,s)  _CANNOT _setvbuf_
  185. #define fscanf  _CANNOT _fscanf_
  186. #define vfprintf(f,fmt,a)  _CANNOT _vfprintf_
  187. #define fgetc(f)  _CANNOT _fgetc_
  188. #define fgets(s,n,f)  _CANNOT _fgets_
  189. #define fputc(c,f)  _CANNOT _fputc_
  190. #define fputs(s,f)  _CANNOT _fputs_
  191. #define getc(f)  _CANNOT _getc_
  192. #define putc(c,f)  _CANNOT _putc_
  193. #define ungetc(c,f)  _CANNOT _ungetc_
  194. #define fread(b,s,c,f)  _CANNOT _fread_
  195. #define fwrite(b,s,c,f)  _CANNOT _fwrite_
  196. #define fgetpos(f,p)  _CANNOT _fgetpos_
  197. #define fseek(f,o,w)  _CANNOT _fseek_
  198. #define fsetpos(f,p)  _CANNOT _fsetpos_
  199. #define ftell(f)  _CANNOT _ftell_
  200. #define rewind(f)  _CANNOT _rewind_
  201. #define clearerr(f)  _CANNOT _clearerr_
  202. #define feof(f)  _CANNOT _feof_
  203. #define ferror(f)  _CANNOT _ferror_
  204. #define __filbuf(f)  _CANNOT __filbuf_
  205. #define __flsbuf(c,f)  _CANNOT __flsbuf_
  206. #define _filbuf(f)  _CANNOT _filbuf_
  207. #define _flsbuf(c,f)  _CANNOT _flsbuf_
  208. #define fdopen(fd,p)  _CANNOT _fdopen_
  209. #define fileno(f)  _CANNOT _fileno_
  210. #define flockfile(f)  _CANNOT _flockfile_
  211. #define ftrylockfile(f)  _CANNOT _ftrylockfile_
  212. #define funlockfile(f)  _CANNOT _funlockfile_
  213. #define getc_unlocked(f)  _CANNOT _getc_unlocked_
  214. #define putc_unlocked(c,f)  _CANNOT _putc_unlocked_
  215. #define popen(c,m)  _CANNOT _popen_
  216. #define getw(f)  _CANNOT _getw_
  217. #define putw(v,f)  _CANNOT _putw_
  218. #define pclose(f)  _CANNOT _pclose_
  219.  
  220. #else /* if PERLIO_NOT_STDIO */
  221. /*
  222.  * PERLIO_NOT_STDIO defined as 0 
  223.  * Declares that both PerlIO and stdio can be used
  224.  */
  225. #endif /* if PERLIO_NOT_STDIO */
  226. #else  /* ifdef PERLIO_NOT_STDIO */
  227. /*
  228.  * PERLIO_NOT_STDIO not defined 
  229.  * This is "source level" stdio compatibility mode.
  230.  */
  231. #include "nostdio.h"
  232. #undef FILE
  233. #define FILE            PerlIO 
  234. #undef fprintf
  235. #undef tmpfile
  236. #undef fclose
  237. #undef fopen
  238. #undef vfprintf
  239. #undef fgetc
  240. #undef getc_unlocked
  241. #undef fputc
  242. #undef putc_unlocked
  243. #undef fputs
  244. #undef ungetc
  245. #undef fread
  246. #undef fwrite
  247. #undef fgetpos
  248. #undef fseek
  249. #undef fsetpos
  250. #undef ftell
  251. #undef rewind
  252. #undef fdopen
  253. #undef popen
  254. #undef pclose
  255. #undef getw
  256. #undef putw
  257. #undef freopen
  258. #undef setbuf
  259. #undef setvbuf
  260. #undef fscanf
  261. #undef fgets
  262. #define fprintf            PerlIO_printf
  263. #define stdin            PerlIO_stdin()
  264. #define stdout            PerlIO_stdout()
  265. #define stderr            PerlIO_stderr()
  266. #define tmpfile()        PerlIO_tmpfile()
  267. #define fclose(f)        PerlIO_close(f)
  268. #define fflush(f)        PerlIO_flush(f)
  269. #define fopen(p,m)        PerlIO_open(p,m)
  270. #define vfprintf(f,fmt,a)    PerlIO_vprintf(f,fmt,a)
  271. #define fgetc(f)        PerlIO_getc(f)
  272. #define fputc(c,f)        PerlIO_putc(f,c)
  273. #define fputs(s,f)        PerlIO_puts(f,s)
  274. #define getc(f)            PerlIO_getc(f)
  275. #ifdef getc_unlocked
  276. #undef getc_unlocked
  277. #endif
  278. #define getc_unlocked(f)    PerlIO_getc(f)
  279. #define putc(c,f)        PerlIO_putc(f,c)
  280. #ifdef putc_unlocked
  281. #undef putc_unlocked
  282. #endif
  283. #define putc_unlocked(c,f)    PerlIO_putc(c,f)
  284. #define ungetc(c,f)        PerlIO_ungetc(f,c)
  285. #if 0
  286. /* return values of read/write need work */
  287. #define fread(b,s,c,f)        PerlIO_read(f,b,(s*c))
  288. #define fwrite(b,s,c,f)        PerlIO_write(f,b,(s*c))
  289. #else
  290. #define fread(b,s,c,f)        _CANNOT fread
  291. #define fwrite(b,s,c,f)        _CANNOT fwrite
  292. #endif
  293. #define fgetpos(f,p)        PerlIO_getpos(f,p)
  294. #define fseek(f,o,w)        PerlIO_seek(f,o,w)
  295. #define fsetpos(f,p)        PerlIO_setpos(f,p)
  296. #define ftell(f)        PerlIO_tell(f)
  297. #define rewind(f)        PerlIO_rewind(f)
  298. #define clearerr(f)        PerlIO_clearerr(f)
  299. #define feof(f)            PerlIO_eof(f)
  300. #define ferror(f)        PerlIO_error(f)
  301. #define fdopen(fd,p)        PerlIO_fdopen(fd,p)
  302. #define fileno(f)        PerlIO_fileno(f)
  303. #define popen(c,m)        my_popen(c,m)
  304. #define pclose(f)        my_pclose(f)
  305.  
  306. #define __filbuf(f)        _CANNOT __filbuf_
  307. #define _filbuf(f)        _CANNOT _filbuf_
  308. #define __flsbuf(c,f)        _CANNOT __flsbuf_
  309. #define _flsbuf(c,f)        _CANNOT _flsbuf_
  310. #define getw(f)            _CANNOT _getw_
  311. #define putw(v,f)        _CANNOT _putw_
  312. #define flockfile(f)        _CANNOT _flockfile_
  313. #define ftrylockfile(f)        _CANNOT _ftrylockfile_
  314. #define funlockfile(f)        _CANNOT _funlockfile_
  315. #define freopen(p,m,f)        _CANNOT _freopen_
  316. #define setbuf(f,b)        _CANNOT _setbuf_
  317. #define setvbuf(f,b,x,s)    _CANNOT _setvbuf_
  318. #define fscanf            _CANNOT _fscanf_
  319. #define fgets(s,n,f)        _CANNOT _fgets_
  320.  
  321. #endif /* ifdef PERLIO_NOT_STDIO */
  322. #endif /* PERLIO_IS_STDIO */
  323.